{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-16T11:28:57.756357Z",
     "start_time": "2025-09-16T11:28:57.753267Z"
    }
   },
   "source": [
    "import os\n",
    "import psutil\n",
    "\n",
    "# def show_memory_info(hint):\n",
    "#     pid = os.getpid()\n",
    "#     p = psutil.Process(pid)\n",
    "#\n",
    "#     info = p.memory_full_info()\n",
    "#     memory = info.uss / 1024. /1024\n",
    "#     print('{} memory used: {} MB'.format(hint, memory))\n",
    "#\n",
    "# def test_iterator():\n",
    "#     show_memory_info('initing iterator')\n",
    "#     list_1 = [i for i in range(100000000)]\n",
    "#     show_memory_info('after iterator initiated')\n",
    "#     print(sum(list_1))\n",
    "#     show_memory_info('after sum called')\n",
    "#\n",
    "# %time test_iterator()\n",
    "\n",
    "# def index_normal(L, target):\n",
    "#     result = []\n",
    "#     for i, num in enumerate(L):\n",
    "#         if num == target:\n",
    "#             result.append(i)\n",
    "#     return result\n",
    "#\n",
    "#\n",
    "# # 使用迭代器实现\n",
    "# def index_generator(L, target):\n",
    "#     for i, num in enumerate(L):\n",
    "#         if num == target:\n",
    "#             yield i\n",
    "#\n",
    "# print(list(index_generator([1, 6, 2, 4, 5, 2, 8, 6, 3, 2], 2)))\n",
    "\n",
    "# result = []\n",
    "# for x in range(10):\n",
    "#     for y in range(5):\n",
    "#         if x * y > 10:\n",
    "#             result.append((x,y))\n",
    "# print(result)\n",
    "\n",
    "# def pay(name, salary=None):\n",
    "#  if salary is not None:\n",
    "#    salary = 11\n",
    "#  pay('jian', 0)\n",
    "#  print(name, \"is compensated\", salary, \"dollars\")\n",
    "\n",
    "# def comp(x,target):\n",
    "#     return x * x > target\n",
    "#\n",
    "# def binary_search(arr,target):\n",
    "#     l,r = 0, len(arr)-1\n",
    "#     ret = -1\n",
    "#     while l <= r:\n",
    "#         m = (l + r) // 2\n",
    "#         if comp(arr[m],target):\n",
    "#             ret = m\n",
    "#             r = m - 1\n",
    "#         else:\n",
    "#             l = m + 1\n",
    "#     return ret\n",
    "#\n",
    "# def solve(arr,target):\n",
    "#     id = binary_search(arr,target)\n",
    "#\n",
    "#     if id != -1:\n",
    "#         return arr[id]\n",
    "#     return -1\n"
   ],
   "outputs": [],
   "execution_count": 11
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
